<?php
// +----------------------------------------------------------------------
// | my
// +----------------------------------------------------------------------
// | Copyright (c) 2016~2022 http://baiyf.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: NickBai <1902822973@qq.com>
// +----------------------------------------------------------------------
namespace app\admin\controller;

use app\admin\my\MyPage;
use app\admin\my\MyConfig;

class Shop extends Base
{
   

    public function shop()
    {
        $my = new MyPage();
        $my->title('分店管理')->suggest('分店管理')
            ->buttonNew("shopEdit")

            ->keyId()->keyText('title', '分部名称')
            ->keyText('mobile', '电话')
            ->keyText('qq', 'QQ')
            ->keyText('address','地址' )
            ->keyMap('status', '状态', ['禁用','启用'])
            ->actionEdit('shopEdit?id=###', '编辑')
            ->actionStatus('delete,disable');

        if ( request()->isAjax() ) {
            return myData($my,'AdminShop');
        } else {
            return $my->fetch();
        }

    }

    public function shopEdit($id='')
    {
        if(request()->isPost()){
           $res = model('admin/Shop')->editData();
           if ($res>0) $this->success('更新成功','shop');
           $this->error('更新失败');
        } else {
            $data=myEdit('admin/Shop',$id);
            $my = new MyConfig();
            return $my->title("编辑分店")->keyId()
                    ->keyText('title', '分店名称')
                    ->keyText('mobile', '手机号')
                    ->keyText('qq', 'QQ')
                    ->keyText('address', '地址')
                  
                    ->data($data)
                    ->fetch();
        }
    }

   
}